package components

import (
	"web/actions"
	"web/store"
	"strings"
	v "github.com/gopherjs/vecty"
	"github.com/gopherjs/vecty/elem"
)

func setDialogErrMsg(value string) {
	store.GetDialog().Dispatch(&actions.SetDialogErrMsg{Value: value})
}

func boolProp(v bool) string {
	if v {
		return "1"
	}
	return ""
}

func toParagraphs(str string) v.List {
	lines := strings.Split(str, "\n")
	result := make(v.List, len(lines))
	for idx, line := range lines {
		result[idx] = elem.Paragraph(
			v.Text(line),
		)
	}
	return result
}
